<template>
  <ul class="todo-main">
    <Item
      v-for="todo in todoList"
      :key="todo.id"
      v-bind="todo"
    />
  </ul>
</template>

<script>
import { v4 as uuidv4 } from "uuid";
import Item from "./Item";
export default {
  name: "List",
  // props: ["todoList", "checkInput", "killOne"],
  components: {
    Item,
  },
  data() {
    return {
      todoList: [
        { id: uuidv4(), thing: "唱", done: false },
        { id: uuidv4(), thing: "跳", done: false },
        { id: uuidv4(), thing: "rap", done: false },
        { id: uuidv4(), thing: "rxx", done: false },
      ],
    };
  },
  mounted() {
    //给$bus绑定一个接受header组件传值的事件newTodo
    this.$bus.$on("newTodo",(newTodo)=>{
      this.todoList.unshift(newTodo);
    })
    
  },
};
</script>

<style scoped>
/*main*/
.todo-main {
  margin-left: 0px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 0px;
}

.todo-empty {
  height: 40px;
  line-height: 40px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding-left: 5px;
  margin-top: 10px;
}
</style>